const express = require("express");
const router = express.Router();
const fs = require("fs");


// 从logs/文件夹里查询日志文件列表
router.get("/", async (req, res) => {
  try {
    // 读取文件夹中的所有文件，不包括子目录
    const files = await fs.readdirSync("./logs/");
    res.json({
        logs: files,
        success: true
    });
  } catch (error) {
    console.error("Error reading directory:", error);
    res.status(500).send("Internal Server Error");
  }
});

module.exports = router;
